<script type="text/javascript" charset="utf-8"> 
$(document).ready(function() {
	$('input.date').datepicker({
			dateFormat: 'yy-mm-dd',
			yearRange: '1900:2020',
			changeMonth: true,
			changeYear: true
	});
});
</script>
<div class="grid_16">
	<h2><?php echo lang('lang_add_user'); ?></h2>
</div>

<?php if(isset($error)) {
	echo '<div class="error">'.$error,'</div>';
} ?>
<?php if(validation_errors()) {
	echo '<div class="error"><h3>'.lang('lang_errors_occured').'</h3> '.validation_errors().'</div>';
}
?>

	<?php echo form_open('admin/users/edit/'.$row['user_id']); ?>
	<div id="form">
	<div class="grid_9">
		<div class="inline">
			
			<p class="top_info"><?php echo lang('lang_required_info'); ?></p>
			<p class="row1">
				<label for="user_username"><?php echo lang('lang_username'); ?>: <em>(<?php echo lang('lang_required'); ?>)</em></label>
				<input tabindex="1" type="text" class="inline_input" name="user_username" id="user_username" value="<?php echo set_value('user_username', $row['user_username']); ?>" />
			</p>
			<p class="row1">
				<label for="user_email"><?php echo lang('lang_email'); ?>: <em>(<?php echo lang('lang_required'); ?>)</em></label>
				<input tabindex="2" type="text" class="inline_input" name="user_email" id="user_email" value="<?php echo set_value('user_email', $row['user_email']); ?>" />
			</p>
			<p class="row1">
				<label for="user_group"><?php echo lang('lang_user_group'); ?>: <em>(<?php echo lang('lang_required'); ?>)</em></label>
					<select tabindex="3" name="user_group" id="user_group">
					<option value=""><?php echo lang('lang_please_select'); ?></option>
					<?php foreach ($groups AS $group) { ?>
						<option value="<?php echo $group['group_id']; ?>"<?php if($group['group_id'] == $row['user_group']) echo 'selected="selected"'; ?>><?php echo $group['group_name']; ?></option>
					<?php } ?>
				</select>
				<?php if ($row['user_group'] == 4): ?>
					<?php echo anchor('admin/users/delete_user_items/'.$row['user_id'], lang('lang_delete_all_content')); ?></a>
				<?php endif; ?>
			</p>
			
			<p class="top_info"><?php echo lang('lang_change_password'); ?></p>
			
			<p class="row1">
				<?php echo form_label(lang('lang_password'). ':', 'user_password'); ?>
				<?php echo form_password('user_password', set_value('user_password'), 'class="inline_input"'); ?>
			</p>
			
			<p class="row1">
				<?php echo form_label(lang('lang_password_confirm'). ':', 'user_password_confirm'); ?>
				<?php echo form_password('user_password_confirm', set_value('user_password_confirm'), 'class="inline_input"'); ?>
			</p>
			
			<?php if ($fields) { ?>
				<p class="top_info"><?php echo lang('lang_extra_fields'); ?></p>
				<?php echo get_admin_fields($fields, $row); ?>
			<?php } ?>
			
			<p class="submit"><input type="submit" name="submit" class="save" value="<?php echo lang('lang_save'); ?>" /></p>
			
			<input type="hidden" name="user_id" value="<?php echo $row['user_id']; ?>" />
		</div>
		
	</div>
	<div class="grid_7">
		<div class="inline">
			<?php if ($fields) { ?>
				<?php echo get_admin_fields($fields); ?>
			<?php } ?>
	</div>
	</div>